﻿using System;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraPrinting;
using DevExpress.XtraRichEdit;

namespace NAGFwk.UI.Modules {
    public partial class WordModule : BaseModule {
        const string FileName = "Document1.docx";
        public WordModule() {
            InitializeComponent();           
        }
        protected override bool AutoMergeRibbon { get { return true; } }
        void view_FocusedRowChanged(object sender, FocusedRowChangedEventArgs e) {
            richEditControl.Options.MailMerge.ActiveRecord = view.ViewRowHandleToDataSourceIndex(view.FocusedRowHandle);
        }
        void richEditControl_StartHeaderFooterEditing(object sender, HeaderFooterEditingEventArgs e) {
            headerFooterToolsRibbonPageCategory1.Visible = true;
            ribbonControl1.SelectedPage = headerFooterToolsDesignRibbonPage1;
        }
        void richEditControl_FinishHeaderFooterEditing(object sender, HeaderFooterEditingEventArgs e) {
            headerFooterToolsRibbonPageCategory1.Visible = false;
        }
        void richEditControl_SelectionChanged(object sender, EventArgs e) {
            tableToolsRibbonPageCategory1.Visible = richEditControl.IsSelectionInTable();
            floatingPictureToolsRibbonPageCategory1.Visible = richEditControl.IsFloatingObjectSelected;
        }
        public override IPrintable PrintableComponent { get { return richEditControl; } }
        public override IPrintable ExportComponent { get { return richEditControl; } }
        public override bool AllowRtfTitle { get { return false; } }
        public override void ShowModule(bool firstShow)
        {
            base.ShowModule(firstShow);
            MainRibbon.SelectedPage = MainRibbon.MergedPages.GetPageByName(homeRibbonPage1.Name);
        }
    }
}
